package org.nanhill.commons.pattern;

import java.util.ArrayList;
import java.util.List;

public class DefaultMonitor<E> implements Monitor<E> {
	private ArrayList<E> values = new ArrayList<E>();

	public void addValue(E v) {
		synchronized (values) {
			values.add(v);
		}

	}

	@SuppressWarnings("unchecked")
	public List<E> getValues() {
		return (List<E>) values.clone();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.nanhill.commons.pattern.Monitor#size()
	 */
	public int size() {
		return values.size();
	}
}
